<?php

class Model_Size extends Model {
    
    private $table = "sizes";
    
    public function getSizeList()
    {
        $sql = "SELECT s.id, s.name FROM {$this->table} AS s";
        return $this->db->query($sql)->fetchAll();
    }
    
    public function getSizesForProduct($id)
    {
        $sql = "SELECT s.* FROM {$this->table} AS s LEFT JOIN products_sizes AS ps ON s.id = ps.size_id
                    WHERE ps.product_id = ?";
        return $this->db->query($sql, $id)->fetchAll();
    }
}